package club.pinea.model;

import club.pinea.utils.StringUtils;
import lombok.Data;

import java.security.NoSuchAlgorithmException;
import java.sql.Timestamp;

/**
 *  推广员对象实体类
 * @author Administrator
 *
 */
@Data
public class Promoter {

	/**
	 * 推广员id
	 */
	private int id;

	/**
	 * 推广员姓名
	 */
	private String name;

	/**
	 * 推广员密码
	 */
	private String password;

	/**
	 * 推广员密码随机盐
	 */
	private String token;

	/**
	 * 推广员上一级id
	 */
	private int parentId;

	/**
	 * 推广员账户余额
	 */
	private int balance;

	/**
	 * 推广员上一次登录时间
	 */
	private Timestamp logTime;

	/**
	 * 邀请码
	 */
	private String invitedCode;

	public Promoter() {}

	public Promoter(String name, String pass) throws NoSuchAlgorithmException {
		this.name = name;
		this.password = StringUtils.encode(pass);
	}

	public Promoter(String name, String pass, String parentId) throws NoSuchAlgorithmException {
		this(name, pass);
		this.invitedCode = parentId;
	}


}
